package composer

import (
	"io"

	"gddgame.cc/galaxy/utils/cache"
	"gddgame.cc/galaxy/utils/def"
	"gddgame.cc/galaxy/utils/orm"
)

type Basis interface {
	def.StoreFactory
	Executor(instance string) orm.Executor
}
type BasisCloser interface {
	Basis
	io.Closer
}

type local struct {
	cache *cache.MemoryCache
}

func newLocal(logger def.Logger) *local {
	return &local{
		cache.Memory(logger),
	}
}

func (l *local) Store(key string) def.Store {
	return l.cache.Store(key)
}
func (l *local) Cache(key string) def.ExpireStore {
	return l.cache.Store(key)
}

func (l *local) Executor(key string) orm.Executor {
	return orm.DefaultExecutor()
}
func (l *local) Close() error {
	return nil
}
